package com.nbsaas.boot.solution.rest.convert;

import com.nbsaas.boot.solution.data.entity.Solution;
import com.nbsaas.boot.solution.api.domain.simple.SolutionSimple;

import com.nbsaas.boot.rest.api.Converter;

/**
* 解决方案-列表对象转换器
*/

public class SolutionSimpleConvert implements Converter<SolutionSimple, Solution> {




@Override
public SolutionSimple convert(Solution source) {
    SolutionSimple result = new SolutionSimple();

                result.setNote(source.getNote());

               try {
                   if(source.getCreator()!=null){
                       result.setCreator(source.getCreator().getId());
                   }
                } catch (Exception ignored) { }

                result.setIntroduce(source.getIntroduce());

                try {
                    if(source.getCreator()!=null){
                        result.setCreatorName(source.getCreator().getName());
                    }
                } catch (Exception ignored) { }

                result.setAddDate(source.getAddDate());

                try {
                    if(source.getSolutionCatalog()!=null){
                        result.setSolutionCatalogName(source.getSolutionCatalog().getName());
                    }
                } catch (Exception ignored) { }

                result.setUrl(source.getUrl());
                result.setViewNum(source.getViewNum());
                result.setName(source.getName());

               try {
                   if(source.getSolutionCatalog()!=null){
                       result.setSolutionCatalog(source.getSolutionCatalog().getId());
                   }
                } catch (Exception ignored) { }

                result.setLogo(source.getLogo());
                if(source.getStoreState()!=null){
                    result.setStoreStateName(String.valueOf(source.getStoreState()));
                }
                result.setStoreState(source.getStoreState());
                result.setId(source.getId());
                result.setLastDate(source.getLastDate());


    return result;
}

}